//
//  TestScrollVC.swift
//  QSActivityIndicatorView
//
//  Created by 火星人 on 2017/11/8.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit

class TestScrollVC: UIViewController {
    
    
    let refreshControl = QSRefreshControl()
    let refreshControlBottom = QSRefreshControl()
    let refreshControlLeft = QSRefreshControl()
    let refreshControlRight = QSRefreshControl()
    
    let scrollView = UIScrollView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        scrollView.frame = self.view.frame
        self.view.addSubview(scrollView)
        
        scrollView.alwaysBounceVertical = true
        scrollView.alwaysBounceHorizontal = true
        
        let v = UIView()
        v.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
        v.backgroundColor = UIColor.brown
        self.scrollView.addSubview(v)
        
        scrollView.backgroundColor = UIColor.groupTableViewBackground
        
        refreshControl.bindTo(scrollView) { (scrollView, indicator) in
            doInMainThreadAfter(3, task: {
                [weak self] in
                self?.refreshControl.stop()
            })
        }
        
        refreshControlBottom.position = .bottom
        refreshControlBottom.bindTo(scrollView) { (scrollView, indicator) in
            doInMainThreadAfter(3, task: {
                [weak self] in
                self?.refreshControlBottom.stop()
            })
        }
        
        refreshControlLeft.position = .left
        refreshControlLeft.bindTo(scrollView) { (scrollView, indicator) in
            doInMainThreadAfter(3, task: {
                [weak self] in
                self?.refreshControlLeft.stop()
            })
        }
        
        refreshControlRight.position = .right
        refreshControlRight.bindTo(scrollView) { (scrollView, indicator) in
            doInMainThreadAfter(3, task: {
                [weak self] in
                self?.refreshControlRight.stop()
            })
        }
    }

}
